(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(a) → b
f(c) → d
f(g(x, y)) → g(f(x), f(y))
f(h(x, y)) → g(h(y, f(x)), h(x, f(y)))
g(x, x) → h(e, x)

Rewrite Strategy: INNERMOST

(1) NestedDefinedSymbolProof (BOTH BOUNDS(ID, ID) transformation)

The following defined symbols can occur below the 0th argument of g: f, g
The following defined symbols can occur below the 1th argument of g: f, g

Hence, the left-hand sides of the following rules are not basic-reachable and can be removed:
f(g(x, y)) → g(f(x), f(y))

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(a) → b
f(c) → d
f(h(x, y)) → g(h(y, f(x)), h(x, f(y)))
g(x, x) → h(e, x)

Rewrite Strategy: INNERMOST

(3) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(4) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(a) → b [1]
f(c) → d [1]
f(h(x, y)) → g(h(y, f(x)), h(x, f(y))) [1]
g(x, x) → h(e, x) [1]

Rewrite Strategy: INNERMOST

(5) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(6) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(a) → b [1]
f(c) → d [1]
f(h(x, y)) → g(h(y, f(x)), h(x, f(y))) [1]
g(x, x) → h(e, x) [1]

The TRS has the following type information:
f :: a:b:c:d:h:e → a:b:c:d:h:e
a :: a:b:c:d:h:e
b :: a:b:c:d:h:e
c :: a:b:c:d:h:e
d :: a:b:c:d:h:e
h :: a:b:c:d:h:e → a:b:c:d:h:e → a:b:c:d:h:e
g :: a:b:c:d:h:e → a:b:c:d:h:e → a:b:c:d:h:e
e :: a:b:c:d:h:e

Rewrite Strategy: INNERMOST

(7) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

f(v0) → null_f [0]
g(v0, v1) → null_g [0]

And the following fresh constants:

null_f, null_g

(8) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(a) → b [1]
f(c) → d [1]
f(h(x, y)) → g(h(y, f(x)), h(x, f(y))) [1]
g(x, x) → h(e, x) [1]
f(v0) → null_f [0]
g(v0, v1) → null_g [0]

The TRS has the following type information:
f :: a:b:c:d:h:e:null_f:null_g → a:b:c:d:h:e:null_f:null_g
a :: a:b:c:d:h:e:null_f:null_g
b :: a:b:c:d:h:e:null_f:null_g
c :: a:b:c:d:h:e:null_f:null_g
d :: a:b:c:d:h:e:null_f:null_g
h :: a:b:c:d:h:e:null_f:null_g → a:b:c:d:h:e:null_f:null_g → a:b:c:d:h:e:null_f:null_g
g :: a:b:c:d:h:e:null_f:null_g → a:b:c:d:h:e:null_f:null_g → a:b:c:d:h:e:null_f:null_g
e :: a:b:c:d:h:e:null_f:null_g
null_f :: a:b:c:d:h:e:null_f:null_g
null_g :: a:b:c:d:h:e:null_f:null_g

Rewrite Strategy: INNERMOST

(9) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

a => 0
b => 1
c => 2
d => 3
e => 4
null_f => 0
null_g => 0

(10) Obligation:

Complexity RNTS consisting of the following rules:

f(z) -{ 1 }→ g(1 + y + f(x), 1 + x + f(y)) :|: z = 1 + x + y, x >= 0, y >= 0
f(z) -{ 1 }→ 3 :|: z = 2
f(z) -{ 1 }→ 1 :|: z = 0
f(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
g(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
g(z, z') -{ 1 }→ 1 + 4 + x :|: z' = x, x >= 0, z = x

Only complete derivations are relevant for the runtime complexity.

(11) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V3),0,[f(V, Out)],[V >= 0]).
eq(start(V, V3),0,[g(V, V3, Out)],[V >= 0,V3 >= 0]).
eq(f(V, Out),1,[],[Out = 1,V = 0]).
eq(f(V, Out),1,[],[Out = 3,V = 2]).
eq(f(V, Out),1,[f(V2, Ret01),f(V1, Ret11),g(1 + V1 + Ret01, 1 + V2 + Ret11, Ret)],[Out = Ret,V = 1 + V1 + V2,V2 >= 0,V1 >= 0]).
eq(g(V, V3, Out),1,[],[Out = 5 + V4,V3 = V4,V4 >= 0,V = V4]).
eq(f(V, Out),0,[],[Out = 0,V5 >= 0,V = V5]).
eq(g(V, V3, Out),0,[],[Out = 0,V6 >= 0,V7 >= 0,V = V6,V3 = V7]).
input_output_vars(f(V,Out),[V],[Out]).
input_output_vars(g(V,V3,Out),[V,V3],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [g/3]
1. recursive [non_tail,multiple] : [f/2]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into g/3
1. SCC is partially evaluated into f/2
2. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations g/3
* CE 8 is refined into CE [10]
* CE 9 is refined into CE [11]


### Cost equations --> "Loop" of g/3
* CEs [10] --> Loop 8
* CEs [11] --> Loop 9

### Ranking functions of CR g(V,V3,Out)

#### Partial ranking functions of CR g(V,V3,Out)


### Specialization of cost equations f/2
* CE 7 is refined into CE [12]
* CE 5 is refined into CE [13]
* CE 4 is refined into CE [14]
* CE 6 is refined into CE [15,16]


### Cost equations --> "Loop" of f/2
* CEs [16] --> Loop 10
* CEs [15] --> Loop 11
* CEs [12] --> Loop 12
* CEs [13] --> Loop 13
* CEs [14] --> Loop 14

### Ranking functions of CR f(V,Out)
* RF of phase [10,11]: [V]

#### Partial ranking functions of CR f(V,Out)
* Partial RF of phase [10,11]:
- RF of loop [10:1,10:2,11:1,11:2]:
V


### Specialization of cost equations start/2
* CE 2 is refined into CE [17,18,19]
* CE 3 is refined into CE [20,21]


### Cost equations --> "Loop" of start/2
* CEs [21] --> Loop 15
* CEs [17,18,19,20] --> Loop 16

### Ranking functions of CR start(V,V3)

#### Partial ranking functions of CR start(V,V3)


Computing Bounds
=====================================

#### Cost of chains of g(V,V3,Out):
* Chain [9]: 0
with precondition: [Out=0,V>=0,V3>=0]

* Chain [8]: 1
with precondition: [V=V3,V+5=Out,V>=0]


#### Cost of chains of f(V,Out):
* Chain [14]: 1
with precondition: [V=0,Out=1]

* Chain [13]: 1
with precondition: [V=2,Out=3]

* Chain [12]: 0
with precondition: [Out=0,V>=0]

* Chain [multiple([10,11],[[14],[13],[12]])]: 2*it(10)+1*it(11)+1*it([13])+1*it([14])+0
Such that:it([13]) =< V/3+1/3
aux(1) =< V+1
aux(2) =< 10/9*V+1/9
aux(3) =< 12/11*V+1/11
it([13]) =< aux(1)
it([14]) =< aux(1)
it(10) =< aux(2)
it(11) =< aux(2)
it([13]) =< aux(2)
it(11) =< aux(3)
it([13]) =< aux(3)

with precondition: [V>=1,Out>=0,7*V+7>=2*Out]


#### Cost of chains of start(V,V3):
* Chain [16]: 1*s(9)+1*s(12)+2*s(13)+1*s(14)+1
Such that:s(8) =< V+1
s(9) =< V/3+1/3
s(10) =< 10/9*V+1/9
s(11) =< 12/11*V+1/11
s(9) =< s(8)
s(12) =< s(8)
s(13) =< s(10)
s(14) =< s(10)
s(9) =< s(10)
s(14) =< s(11)
s(9) =< s(11)

with precondition: [V>=0]

* Chain [15]: 1
with precondition: [V=V3,V>=0]


Closed-form bounds of start(V,V3):
-------------------------------------
* Chain [16] with precondition: [V>=0]
- Upper bound: 14/3*V+8/3
- Complexity: n
* Chain [15] with precondition: [V=V3,V>=0]
- Upper bound: 1
- Complexity: constant

### Maximum cost of start(V,V3): 14/3*V+8/3
Asymptotic class: n
* Total analysis performed in 143 ms.

(12) BOUNDS(1, n^1)